#################################
#### figure_s1-2.R           ####
#### Generates Figures S1-2  ####
#################################

fig_weight_base = data |> 
  ggplot(aes(x = weight)) +
  geom_histogram() +
  theme_prl() +
  labs(y = "N Respondents", x = "Weight (unadjusted)")

fig_weight_adj = data |> 
  ggplot(aes(x = wt_adj)) +
  geom_histogram() +
  theme_prl() +
  labs(y = "N Respondents", x = "Weight (adjusted)")

fig_s1 = fig_weight_base + fig_weight_adj
print(fig_s1)

ggsave(here("Plots", "figure_s1.pdf"), fig_s1,
       dpi = 600, units = "in", width = 8, height = 5)

fig_s2 = data|> 
  ggplot(aes(x = st_wt_adj)) +
  geom_histogram() +
  facet_wrap(~ state, scales = "free_y", ncol = 6) +
  theme_prl() +
  labs(y = NULL, x = NULL)

print(fig_s2)

ggsave(here("Plots", "figure_s2.pdf"), fig_s2,
       dpi = 600, units = "in", width = 10, height = 12)

# Weight Convergence

data |> 
  distinct(state, converge) |> 
  arrange(converge, state) |> 
  print(n = 100)
